package ar.com.ford.it.fullEconomics.facade;

import java.util.Collection;
import ar.com.ford.it.fullEconomics.exception.FullEconomicsException;
import ar.com.ford.it.fullEconomics.logic.PaymentPolicyLogic;
import ar.com.ford.it.fullEconomics.persistence.dto.Teese05Paypolvers;
import ar.com.ford.it.fullEconomics.struct.PaymentPolicyCreateStruct;
import ar.com.ford.it.fullEconomics.struct.PaymentPolicyDisplayStruct;
import ar.com.ford.it.fullEconomics.wslx.FullEconomicsWslxUser;

public class PaymentPolicyFacade {

    /**
     * Busca las politicas de pago segun el filtro especificado
     * 
     * @param findPayPolVers
     * @return
     * @throws FullEconomicsException
     */
    public Collection<PaymentPolicyDisplayStruct> findPaymentPolicies(
                                                                      Teese05Paypolvers findPayPolVers)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        Collection<PaymentPolicyDisplayStruct> ret = logic
                .findPaymentPolicies(findPayPolVers);

        return ret;
    }

    /**
     * busca las politicas de pago mas recientes que esten aprovadas segun el
     * filtro especificado
     * 
     * @param findPayPolVers
     * @return
     * @throws FullEconomicsException
     */
    public Collection<PaymentPolicyDisplayStruct> findLastAprovedPaymentPolicies(
                                                                                 Teese05Paypolvers findPayPolVers)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        Collection<PaymentPolicyDisplayStruct> ret = logic
                .findLastAprovedPaymentPolicies(findPayPolVers);

        return ret;
    }

    /**
     * se crea una nueva politica de pago
     * 
     * @param payPolStrc
     * @return
     * @throws FullEconomicsException
     */
    public Teese05Paypolvers createPayPol(PaymentPolicyCreateStruct payPolStrc)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        Teese05Paypolvers ret = logic.createPayPol(payPolStrc);
        return ret;
    }


    /**
     * se crea una nueva version de la politica de pago
     * 
     * @param payPolVers
     * @param user
     * @return
     * @throws FullEconomicsException
     */
    public Teese05Paypolvers createNewVersion(Teese05Paypolvers payPolVers,
                                              FullEconomicsWslxUser user)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        Teese05Paypolvers ret = logic.createPayPolVers(payPolVers, user);
        return ret;
    }

    /**
     * actualiza los cambios hechos en la version de la politica de pago
     * 
     * @param payPolVers
     * @param user
     * @throws FullEconomicsException
     */
    public void updateVersion(Teese05Paypolvers payPolVers,
                              FullEconomicsWslxUser user)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        logic.updateVersion(payPolVers, user);
    }

    /**
     * propone la politica de pago seleccionada para se aprobada
     * @param payPolVers
     * @param user
     * @throws FullEconomicsException
     */
    public void proposePaymentPolicy(Teese05Paypolvers payPolVers,
                                     FullEconomicsWslxUser user)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        logic.proposePaymentPolicy(payPolVers, user);
    }

    /**
     * se aprova la politica de pago
     * @param payPolVers
     * @param user
     * @throws FullEconomicsException
     */
    public void approvePaymentPolicy(Teese05Paypolvers payPolVers,
                                     FullEconomicsWslxUser user)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        logic.approvePaymentPolicy(payPolVers, user);
    }
    
    /**
     * se aprova la politica de pago
     * @param payPolVers
     * @param user
     * @throws FullEconomicsException
     */
    public void approveAllPaymentPolicy(Collection<PaymentPolicyDisplayStruct> payPolVersCol,
                                     FullEconomicsWslxUser user)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        logic.approveAllPaymentPolicy(payPolVersCol, user);
    }
    
    /**
     * devuelve la politica de pago mas reciente que este aprovada.
     * 
     * @param payPolVers
     * @return
     * @throws FullEconomicsException
     */
    public Teese05Paypolvers getPrevAprovedVersion(Teese05Paypolvers payPolVers)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        Teese05Paypolvers ret = logic.getPrevAprovedVersion(payPolVers);
        return ret;
    }
    
    /**
     * borra la politica de pago
     * 
     * @param payPolVers
     * @return
     * @throws FullEconomicsException
     */
    public void deletePaymentPolicyVersion(Teese05Paypolvers payPolVers)
            throws FullEconomicsException {
        PaymentPolicyLogic logic = new PaymentPolicyLogic();
        logic.deletePaymentPolicyVersion(payPolVers);
    }
}
